package com.oba.base.dao.pager;

import javax.faces.event.ActionEvent;
import javax.faces.event.PhaseId;

/**
 * 延时事件
 * @author han
 */
public class DelayActionEvent extends ActionEvent {
	private static final long serialVersionUID = 1L;
	private int delayLevel = 1;
	private ActionEvent event;

	public DelayActionEvent(ActionEvent event, int delayLevel) {
		super(event.getComponent());
		this.event = event;
		this.delayLevel = delayLevel;
	} 

	@Override
	public void queue() {
		if (delayLevel <= 0) {
			event.queue();
		} else {
			delayLevel--;
			super.queue();
		}
	}

	@Override
	public void setPhaseId(PhaseId phaseId) {
		super.setPhaseId(phaseId);
		event.setPhaseId(phaseId);
	}

}
